﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script type="text/javascript">
        $(document).ready(function() {
            $.ajax({
                url: "Service.asmx/CallService1",
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify({ skey: "module", model: "" }),
                success: function(data) {
                    data = JSON.parse(data.d);
                    var content = '';
                    $(data).each(function() {
                        var cUrl = escape(myUtils.format("detail.htm?mid={0}", this.ID));
                        var url = myUtils.format("index.htm?content={0}", cUrl);
                        content += '<div class="item">' +
                                        '<h2>' +
                                            '<span class="title" title="{0}">{1}</span><a href="{2}" class="more">more</a></h2>' +
                                        '<div id="{3}{4}"></div>' +
                                    '</div>';
                        content = myUtils.format(content, this.Detail, this.Name, url, this.Code, this.ID);
                    });
                    content += '<div style="clear: both;"></div>';
                    $("#temp").html(content);
                    $(data).each(function() {
                        AppendItemInfo(this.ID, this.Code);
                    });
                },
                error: function(x, e) {
                    $("#temp").html(x.responseText);
                }
            });
        });

        function AppendItemInfo(id, code) {
            $.ajax({
                url: "Service.asmx/CallService1",
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify({ skey: "item", model: myUtils.format("{MID:'{0}'}", id) }),
                success: function(data) {
                    data = JSON.parse(data.d);
                    var content = '';
                    content += '<ul>';
                    $(data).each(function(i) {
                        if (i > 9) {
                            return false;
                        } else {
                            var cdate = myUtils.formatTime(this.CreateDate, "MM/dd hh:mm");
                            var cUrl = escape(myUtils.format("detail.htm?mid={0}&id={1}", this.MID, this.ID));
                            var url = myUtils.format("index.htm?content={0}", cUrl);
                            content += myUtils.format('<li><a href="{0}">{1}</a></li>', url, this.Title);
                        }
                    });
                    content += '</ul>';
                    $("#" + code + id).html(content);
                },
                error: function(x, e) {
                    $("#" + code + id).html(x.responseText);
                }
            });
        }
    </script>

</head>
<body>
    <div id="temp">
        
    </div>
</body>
</html>
